/*
-----------------------------------------------------------------------------
This source file is part of DIVA
The project of Engineering Lab, dept. of CSIE, NTNU.

Copyright (c) 2000-2006 The Engineering Lab, dept. of CSIE, NTNU.
-----------------------------------------------------------------------------
Filename:    DIVA_ReferenceVM.h
Description: setup this file at 2007/06/26 by Mike Chiu according to design doc v0.51

-----------------------------------------------------------------------------
*/

/*------------------------------------------------------------*/
#ifndef _dummyVM_H_
#define	_dummyVM_H_
/*------------------------------------------------------------*/

#include "DIVA_VM.h"
#include "ReferenceVM.h"
#include "WOP_Entry.h"

class dummyVM: public ReferenceVM {
private:
	WOP_Entry* parent_wop ; 
	DIVA_VM* parent_vm ;  // a pointer a->b. a is the parent_vm b is this dummy vm. 
public:

	// constructor
	dummyVM(WOP_Entry * some_ref_entry, DIVA_VM * body_vm);

	// destructor
	~dummyVM();

	/** a reference VM has a _pointedVM which is the destination VM. */
	void clearPointedVM() { _pointedVM = NULL ; }  

	bool hasNULLvalue() { 
		if (parent_wop->getVal() == "null" || 
			parent_wop->getVal() == "0x0" ) return true ;
		else return false ;
	}		
	void set_movable(bool v) {
		if (_pointedVM) 
			_pointedVM->set_movable(v);
		else 
			assert(false);
	} 
	Ogre::Vector3 getPosition();
	Ogre::Vector3 getWorldPosition();
	void setParentVM(DIVA_VM* parent_vm);
	DIVA_VM * getParentVM() ;

	virtual Ogre::SceneNode* getSceneNode(void) {
		if (_pointedVM) { 
			 return _pointedVM->getSceneNode();
		} else return NULL ;
	}
	virtual Ogre::SceneNode* getParentSceneNode(void) {
		if (_pointedVM) { 
			 return _pointedVM->getParentSceneNode();
		} else return NULL ;
	}
	virtual void setParentSceneNode(Ogre::SceneNode *n) {
		if (_pointedVM) { 
			 _pointedVM->setParentSceneNode(n);
		} 
		else 
			assert(false);
	}
	virtual std::string getSceneNodeName() {
		if (_pointedVM) { 
			 return _pointedVM->getSceneNodeName();
		} else 
			assert(false);
		return "" ;
	}
	virtual void set_default_values() { assert(false); }
	// the overridden method of OgreVM
	void setBodyScale(Ogre::Vector3);
	Ogre::Vector3 getOriginalBodySize();
	Ogre::Vector3 getActualSize();
	bool isBodyScaleWrtSceneNode();
	Ogre::Vector3 getBodyScale();
	bool isDraggedOn();

	// override all the methods as proxy pattern
	void VMPicked(Ogre::Real x,Ogre::Real y,Ogre::Real z);
	void VMSetVisible(bool vis);
	void enableVMDragged() { if (_pointedVM) _pointedVM->enableVMDragged();}
	void disableVMDraggeed() {if (_pointedVM)_pointedVM->disableVMDraggeed(); }
	void enableVMAnimation() {if (_pointedVM) _pointedVM->enableVMAnimation(); }
	void disableVMAnimation() { if (_pointedVM)_pointedVM->disableVMAnimation(); }
	bool isVMAnimationOn() {
		if (_pointedVM) 
		return _pointedVM->isVMAnimationOn(); else return false; 
	} 
	void setPosition(Ogre::Vector3);
private:
	void unfoldWOP();

};
/*------------------------------------------------------------*/
#endif	//#ifndef _dummyVM_H_
/*------------------------------------------------------------*/